Use case: ICACHE maintenance operations in interrupt mode ¶
This use case shows how to run an ICACHE invalidate operation in interrupt mode, comparing HAL1 and HAL2.
Sequence diagram ¶
Code snippet ¶
|
HAL1 |
HAL2 |
|---|---|
/* Enable ICACHE */
HAL_ICACHE_Enable();
/* Start invalidate in interrupt mode */
if (HAL_ICACHE_Invalidate_IT() != HAL_OK)
{
Error_Handler();
}
/* In ICACHE_IRQHandler(): */
/* HAL_ICACHE_IRQHandler(); */
/* Completion notification */
/* void HAL_ICACHE_InvalidateCompleteCallback(void) { ... } */
|
/* Optional: register callback */
(void)HAL_ICACHE_RegisterInvalidateCompleteCallback(&hicache1, myICACHE_InvalidateCompleteCallback);
/* Start ICACHE */
if (HAL_ICACHE_Start(&hicache1, HAL_ICACHE_IT_NONE) != HAL_OK)
{
Error_Handler();
}
/* Start invalidate in interrupt mode */
if (HAL_ICACHE_Invalidate_IT(&hicache1) != HAL_OK)
{
Error_Handler();
}
/* In ICACHE_IRQHandler(): */
/* HAL_ICACHE_IRQHandler(&hicache1); */
|
Key changes ¶
HAL2 uses handle-based APIs and a start step (
HAL_ICACHE_Start()), while HAL1 usesHAL_ICACHE_Enable().HAL2 supports callback registration (when
USE_HAL_ICACHE_REGISTER_CALLBACKSis enabled) for invalidate-complete notification.HAL2 keeps the same high-level interrupt flow (request invalidate, then handle in IRQ), but with updated signatures and naming.
![@startuml
participant "User\nApplication" order 1
participant "ICACHE\nDriver" order 2
participant "ICACHE_IRQHandler" order 3
"User\nApplication"->"ICACHE\nDriver": HAL_ICACHE_Enable
"ICACHE\nDriver"-->"User\nApplication":HAL_OK
note left: return\nstatus
"User\nApplication"->"ICACHE\nDriver": HAL_ICACHE_Invalidate_IT
note right: Invalid ICACHE interruption enabled\nthen ICACHE disabled
"ICACHE\nDriver"-->"User\nApplication":HAL_OK or HAL_ERROR
note left: return\nstatus
== Interruption Service Routine ==
"ICACHE_IRQHandler" <-]:Invalidate\ninterrupt
"ICACHE_IRQHandler" -> "ICACHE\nDriver" : HAL_ICACHE_IRQHandler
note left: Interruption execution
"ICACHE\nDriver"->"User\nApplication":HAL_ICACHE_InvalidateCompleteCallback
@enduml](../../../../../_images/plantuml-9d19175a61b322f6da477f0540a9140245f51238.png)
